<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pgh="http://tecnologie-web.studenti.math.unipd.it/tecweb/~ccardin/"
    exclude-result-prefixes="pgh">
        
<xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes' omit-xml-declaration='yes'/>
    
    <!-- set the page index -->
    <xsl:variable name="pageId" select="'__PAGEID__'"/>
    <xsl:variable name="precursor" select="pgh:pageheader/pgh:pages/pgh:page[@linkId=$pageId]/pgh:precursorId"/>

    <xsl:template match="/">
        <p>
			<xsl:choose>
            <xsl:when test="$pageId=$precursor">
                You are here: <xsl:value-of select="pgh:pageheader/pgh:pages/pgh:page[@linkId=$pageId]/pgh:title"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="pgh:pageheader/pgh:pages/pgh:page[@linkId=$precursor]"/><xsl:value-of select="pgh:pageheader/pgh:pages/pgh:page[@linkId=$pageId]/pgh:title"/>
            </xsl:otherwise>
            </xsl:choose>
        </p>
    </xsl:template>
    
    <xsl:template match="pgh:page">
        <xsl:variable name="prec" select="pgh:precursorId"/>
        <xsl:if test="@linkId=pgh:precursorId">
            You are here: 
        </xsl:if>
        <xsl:apply-templates select="preceding-sibling::node()[@linkId=$prec]"/>
        <a href="{@linkId}.cgi"><xsl:value-of select="pgh:title"/></a> &#62;
    </xsl:template>
	
</xsl:stylesheet>
